package com.air.designmodel.three;


/**
 * 布告板,显示最新数据
 *
 * @author shent
 */
public class CurrentConditionsDisplay implements Observer, DisplayElement {
    private float templature;
    private float humidity;
    private Subject weatherData;

    public CurrentConditionsDisplay(Subject weatherData) {
        this.weatherData = weatherData;
        weatherData.registerObserver(this);
    }

    @Override
    public void update(float templature, float humidity, float pressure) {
        this.templature = templature;
        this.humidity = humidity;
        display();
    }

    @Override
    public void notObserver() {
        weatherData.removeObserver(this);
    }

    @Override
    public void observer() {
        weatherData.registerObserver(this);
    }

    @Override
    public void display() {
        System.out.println("当前条件:" + templature + "摄氏度," + humidity + "%湿度");
    }
}
